﻿using System;
using System.Collections.Generic;
using System.Text;
using Abp.Domain.Entities;

namespace KelonProud.Domain.Entitys
{
    public abstract class NoneEntity: NoneEntity<int>
    {
    }


    [Serializable]
    public abstract class NoneEntity<TPrimaryKey> : Entity<TPrimaryKey>, IEntity<TPrimaryKey>
    {
        public override bool IsTransient()
        {
            if (typeof(TPrimaryKey) == typeof(short))
            {
                return Convert.ToInt16(Id) < 0;
            }

            if (typeof(TPrimaryKey) == typeof(byte))
            {
                return Convert.ToInt32(Id) < 0;
            }

            if (typeof(TPrimaryKey) == typeof(int))
            {
                return Convert.ToInt32(Id) < 0;
            }

            if (typeof(TPrimaryKey) == typeof(long))
            {
                return Convert.ToInt64(Id) < 0;
            }

            return EqualityComparer<TPrimaryKey>.Default.Equals(Id, default(TPrimaryKey));
        }
    }
}
